#include "../../third/include/aip-cpp-sdk/speech.h"
#include <iostream>
#include <json/value.h>

void asr(aip::Speech& client)
{
    // 读取语音文件
    std::string file_content;
    aip::get_file_content("16k.pcm", &file_content);

    Json::Value ret = client.recognize(file_content, "pcm", 16000, aip::null);
    if(ret["err_no"].asInt()) {
        std::cout << ret["err_msg"].asString() << std::endl;
        return;
    }
    std::cout << ret["result"][0].asString() << '\n';
}

int main()
{
    // 设置APPID/AK/SK
    std::string app_id = "xxxxxxxxxxxxxxxxxxxx";
    std::string api_key = "xxxxxxxxxxxxxxxxxxxx";
    std::string secret_key = "xxxxxxxxxxxxxxxxxxxx";

    aip::Speech client(app_id, api_key, secret_key);

    asr(client);

    return 0;
}